#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

void solve() {
    int n, m, q, flag;
    cin >> n >> m >> q;
    vector<pii> p;
    p.push_back({m, m});
    for(int i = 1; i <= q; i++) {
        cin >> flag;
        vector<pii> copy;
        for(auto u : p) {
            int a = u.first, b = u.second;
            if(flag < a) {
                copy.push_back({a - 1, b});
            }else if(flag > b) {
                copy.push_back({a, b + 1});
            }else{
                copy.push_back({1, 1});
                copy.push_back({n, n});
                if(a != b) {
                    copy.push_back({a, b});
                }
            }
        }
        sort(copy.begin(), copy.end());
        p.clear();
        for(auto u : copy) {
            int a = u.first, b = u.second;
            if(p.empty() || p.back().second < a) {
                p.push_back({a, b});
            }else{
                p.back().second = max(b, p.back().second);
            }
        }
        int ans = 0;
        for(auto u : p) {
            int a = u.first, b = u.second;
            ans += (b - a + 1);
        }
        cout << ans << ' ';
    }
    cout << '\n';
}

int main() {
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}